﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace ERPStore.Models
{
	/// <summary>
	/// Origine d'une visite
	/// </summary>
	[Serializable]
	[DataContract]
	public abstract class LeadSourceBase
	{
		/// <summary>
		/// Identifiant unique
		/// </summary>
		/// <value>The id.</value>
		[DataMember]
		public abstract string Id { get; }
		/// <summary>
		/// Nom de l'origine
		/// </summary>
		/// <value>The name.</value>
		[DataMember]
		public abstract string Name { get; }
		/// <summary>
		/// Description
		/// </summary>
		/// <value>The description.</value>
		[DataMember]
		public abstract string Description { get; }

		/// <summary>
		/// Identifiant de la source dans une URL
		/// </summary>
		[DataMember]
		public abstract string TrackSourceId { get; }

		/// <summary>
		/// Type de source (CPC / Organic)
		/// </summary>
		[DataMember]
		public abstract string Medium { get; }

		/// <summary>
		/// Ordre de matching
		/// </summary>
		/// <value>The order.</value>
		public virtual int Order 
		{ 
			get { return 0; } 
		}

		/// <summary>
		/// Type de source de trafic
		/// </summary>
		[DataMember]
		public abstract LeadSourceType LeadSourceType { get; }

		/// <summary>
		/// Indique si la source est bien celle qui a généré le click
		/// </summary>
		/// <param name="sourceUrl">The source URL.</param>
		/// <param name="landingUrl">The landing URL.</param>
		/// <returns></returns>
		public virtual bool Match(Uri sourceUri, Uri landingUri, out string keywords, out string subHost, out decimal amount)
		{
			keywords = null;
			subHost = null;
			amount = 0;
			return false;
		}

		protected virtual string GetKeywords(System.Uri uri)
		{
			return null;
		}
	}
}
